#include "searchper.h"
#include "ui_searchper.h"
#include "mainwindow.h"
#include "searchwin.h"
#include <vector>
#include "teacher.h"
#include "student.h"
#include "paper.h"
#include "program.h"
#include "person.h"
#include <QTextEdit>
using namespace std;
extern int n;
extern vector <Teacher*> tdata;
extern vector <student*> sdata;
searchper::searchper(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::searchper)
{
    ui->setupUi(this);   
    if((unsigned int)n<tdata.size()){
        ui->label_9->setText("   职称：");
        ui->label_10->setText("研究方向：");
        ui->lineEdit->setText(tdata[n]->findnumber());
        ui->lineEdit_2->setText(tdata[n]->findname());
        if(tdata[n]->findsex())
        ui->lineEdit_3->setText("男");
        else
        ui->lineEdit_3->setText("女");
        ui->lineEdit_4->setText(QString::number(tdata[n]->findage()));
        ui->lineEdit_5->setText(tdata[n]->findcollege());
        ui->lineEdit_6->setText(tdata[n]->findtime());
        ui->lineEdit_7->setText(QString::number(tdata[n]->findprogram()));
        ui->lineEdit_8->setText(QString::number(tdata[n]->findpaper()));
        ui->lineEdit_9->setText(tdata[n]->findlevel());
        ui->lineEdit_10->setText(tdata[n]->finddirection());
    }
    else{
        ui->label_9->setText("   导师：");
        ui->label_10->setText("学生类别：");
        ui->lineEdit->setText(sdata[n-tdata.size()]->findnumber());
        ui->lineEdit_2->setText(sdata[n-tdata.size()]->findname());
        if(sdata[n-tdata.size()]->findsex())
        ui->lineEdit_3->setText("男");
        else
        ui->lineEdit_3->setText("女");
        ui->lineEdit_4->setText(QString::number(sdata[n-tdata.size()]->findage()));
        ui->lineEdit_5->setText(sdata[n-tdata.size()]->findcollege());
        ui->lineEdit_6->setText(sdata[n-tdata.size()]->findtime());
        ui->lineEdit_7->setText(QString::number(sdata[n-tdata.size()]->findprogram()));
        ui->lineEdit_8->setText(QString::number(sdata[n-tdata.size()]->findpaper()));
        ui->lineEdit_9->setText(sdata[n-tdata.size()]->findteach());
        ui->lineEdit_10->setText(sdata[n-tdata.size()]->findtype());
    }
}

searchper::~searchper()
{
    delete ui;
}

void searchper::on_pushButton_clicked()
{
    closeEvent(0);
    searchwin*p=new(searchwin);
    p->show();
}
